#ifndef RTHTTPURL_H
#define RTHTTPURL_H

#include "RtReferenceControl.h"
#include "RtStdCpp.h"

class RT_API_EXPORT CRtHttpUrl : public CRtReferenceControlSingleThread
{
public:
	CRtHttpUrl();
	virtual ~CRtHttpUrl();

	/// aSpec is such as "http://www.xxx.com:8080"
	BOOL Init(const CRtString &aSepc);
	
	CRtString GetAsciiSpec();
	
	/**
	 * ServerName is server IP address to connect to in format of "address[:port]", 
	 * if port part is empty, then use default value (80 for HTTP and 443 for HTTPS).
	 */
	BOOL SetNameAndPort(const CRtString &aSrvName);
	WORD GetPort();
	CRtString GetHostName();
	void SetPort(WORD aPort);
	CRtString GetNameAndPort(BOOL bAddPort = FALSE);
	void SetPath(const CRtString &aObjName);
	CRtString GetPath();
	CRtString GetScheme();

	static LPCSTR s_pszSchemeHttp;
	static LPCSTR s_pszSchemeHttps;
	static LPCSTR s_pszSchemeFile;
	
private:
	WORD GetDefaultPort();

	CRtString	m_strSpec;
	CRtString	m_strScheme;
	CRtString	m_strPath;
	CRtString	m_strHostName;
	WORD	m_wPort;
};

#endif // !RTHTTPURL_H
